package addressBook;
import java.util.*;

public class Entry {
	
	private String _Name;
	private String _LastName;
	private String _PatrName;
	
	private Map<String,String> _fields;
	
	public Entry (String lastname, String name, String patrname) {
		_Name = name;
		_LastName = lastname;
		_PatrName = patrname;
		_fields = new HashMap<String,String>();
	}
	
	public boolean addField (String fieldName, String value) {
		if (!_fields.containsKey(fieldName)){
			_fields.put(fieldName, value);
			return true;
		}
		return false;
	}
	
	public boolean modifyField (String fieldName, String value) {
		if (_fields.containsKey(fieldName)){
			_fields.put(fieldName, value);
			return true;
		}
		return false;
	}
	
	public boolean removeField (String fieldName) {
		if (_fields.containsKey(fieldName)) {
			_fields.remove(fieldName);
			return true;
		}
		return false;	
	}
	
	public String getFieldValue (String fieldName) {
		if (_fields.containsKey(fieldName))
			return _fields.get(fieldName);
		return null;
	}
	
	public boolean containsField (String fieldName) {
		if (!_fields.containsKey(fieldName))
			return false;
		return true;
	}
	
	public Map<String,String> getFieldsMap () 
	{
		return _fields;
	}
	
	public String getName (){
		return _Name;
	}
	
	public void setName (String name){
		_Name = name;
	}
	
	public String getLastName (){
		return _LastName;
	}
	
	public void setLastName (String lastname){
		_LastName = lastname;
	}
	
	public String getPatrName (){
		return _PatrName;
	}
	
	public void setPatrName (String patrname){
		_PatrName = patrname;
	}
	
	public boolean equals (Object obj)
	{
		if (obj instanceof Entry)
		{
			Entry en = (Entry) obj;
			if ((_Name.equals(en.getName())) && (_LastName.equals(en.getLastName())) && (_PatrName.equals(en.getPatrName())))
			return true;
		}
		return false;
	}
}
